package com.appbee.news.client.ui;

import javax.inject.Inject;

import com.appbee.core.client.design.PageStyle;
import com.appbee.core.client.design.editablecelllist.EditableCellListResources;
import com.appbee.core.client.templates.CommonTemplates;
import com.appbee.news.client.activty.RollingNewsActivity;
import com.appbee.news.client.text.NewsStrings;
import com.appbee.news.shared.NewsProxy;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.cellview.client.CellWidget;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;

public class RollingNewsView extends Composite implements
		RollingNewsActivity.View
{

	private static RollingNewsViewUiBinder uiBinder = GWT
			.create(RollingNewsViewUiBinder.class);

	interface RollingNewsViewUiBinder extends UiBinder<Widget, RollingNewsView>
	{
	}

	@UiField(provided = true)
	NewsStrings newsStrings;

	@UiField(provided = true)
	PageStyle style;

	@UiField(provided = true)
	INewsStyle newsStyle;

	@UiField(provided = true)
	CellWidget<NewsProxy> newsCell;

	@Inject
	public RollingNewsView(	NewsStrings newsStrings,
							PageStyle style,
							EditableCellListResources listRes,
							INewsStyle newsStyle,
							CommonTemplates html)
	{
		this.newsStrings = newsStrings;
		this.style = style;
		this.newsStyle = newsStyle;
		newsCell = new CellWidget<NewsProxy>(new NewsCell(false, html,
				newsStyle, listRes, null));
		initWidget(uiBinder.createAndBindUi(this));
	}

	@Override
	public void showNews(NewsProxy newsProxy)
	{
		newsCell.setValue(newsProxy);
	}

}
